package com.bi.cloud.config;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.data.redis.connection.RedisConnectionFactory;
import org.springframework.security.oauth2.provider.token.TokenStore;
import org.springframework.security.oauth2.provider.token.store.redis.JdkSerializationStrategy;
import org.springframework.security.oauth2.provider.token.store.redis.RedisTokenStore;


//@Configuration
public class RedisTokenStoreConfig {

  //  @Autowired
    private RedisConnectionFactory redisConnectionFactory;

  //  @Bean
    /*public TokenStore tokenStore (){
        RedisTokenStore redisTokenStore = new RedisTokenStore(redisConnectionFactory);
        // redis：oauth2使用的是java二进制序列化的方式，存在一些问题，最好能重写RedisTokenStore序列化方式
        //1. 如果UserDetails定义的字段发生增删，已存在的token，访问校验的时候，就会发生序列化错误；
        //2. 如果去redis中查看某个token的内容的时候，会发现全是乱码，完全看不懂；
        redisTokenStore.setSerializationStrategy(new JdkSerializationStrategy());
        return redisTokenStore;
    }*/
}
